import*as t from"../../core/i18n/i18n.js";import*as e from"../../core/sdk/sdk.js";import*as n from"../../core/common/common.js";import*as i from"../../core/host/host.js";import*as o from"../../ui/components/icon_button/icon_button.js";import*as r from"../../ui/legacy/legacy.js";const s={noThrottling:"No throttling",noInternetConnectivity:"No internet connectivity",lowendMobile:"Low-end mobile",slowGXCpuSlowdown:"Slow 3G & 6x CPU slowdown",midtierMobile:"Mid-tier mobile",fastGXCpuSlowdown:"Fast 3G & 4x CPU slowdown",custom:"Custom",checkNetworkAndPerformancePanels:"Check Network and Performance panels"},a=t.i18n.registerUIStrings("panels/mobile_throttling/ThrottlingPresets.ts",s),l=t.i18n.getLocalizedString.bind(void 0,a);class d{static getNoThrottlingConditions(){return{title:"function"==typeof e.NetworkManager.NoThrottlingConditions.title?e.NetworkManager.NoThrottlingConditions.title():e.NetworkManager.NoThrottlingConditions.title,description:l(s.noThrottling),network:e.NetworkManager.NoThrottlingConditions,cpuThrottlingRate:e.CPUThrottlingManager.CPUThrottlingRates.NoThrottling}}static getOfflineConditions(){return{title:"function"==typeof e.NetworkManager.OfflineConditions.title?e.NetworkManager.OfflineConditions.title():e.NetworkManager.OfflineConditions.title,description:l(s.noInternetConnectivity),network:e.NetworkManager.OfflineConditions,cpuThrottlingRate:e.CPUThrottlingManager.CPUThrottlingRates.NoThrottling}}static getLowEndMobileConditions(){return{title:l(s.lowendMobile),description:l(s.slowGXCpuSlowdown),network:e.NetworkManager.Slow3GConditions,cpuThrottlingRate:e.CPUThrottlingManager.CPUThrottlingRates.LowEndMobile}}static getMidTierMobileConditions(){return{title:l(s.midtierMobile),description:l(s.fastGXCpuSlowdown),network:e.NetworkManager.Fast3GConditions,cpuThrottlingRate:e.CPUThrottlingManager.CPUThrottlingRates.MidTierMobile}}static getCustomConditions(){return{title:l(s.custom),description:l(s.checkNetworkAndPerformancePanels)}}static getMobilePresets(){return[d.getMidTierMobileConditions(),d.getLowEndMobileConditions(),d.getCustomConditions()]}static getAdvancedMobilePresets(){return[d.getOfflineConditions()]}static networkPresets=[e.NetworkManager.Fast3GConditions,e.NetworkManager.Slow3GConditions,e.NetworkManager.OfflineConditions];static cpuThrottlingPresets=[e.CPUThrottlingManager.CPUThrottlingRates.NoThrottling,e.CPUThrottlingManager.CPUThrottlingRates.MidTierMobile,e.CPUThrottlingManager.CPUThrottlingRates.LowEndMobile]}globalThis.MobileThrottling=globalThis.MobileThrottling||{},globalThis.MobileThrottling.networkPresets=d.networkPresets;var c=Object.freeze({__proto__:null,ThrottlingPresets:d});const g={disabled:"Disabled",presets:"Presets",custom:"Custom"},h=t.i18n.registerUIStrings("panels/mobile_throttling/NetworkThrottlingSelector.ts",g),u=t.i18n.getLocalizedString.bind(void 0,h);class w{populateCallback;selectCallback;customNetworkConditionsSetting;options;constructor(t,n,i){this.populateCallback=t,this.selectCallback=n,this.customNetworkConditionsSetting=i,this.customNetworkConditionsSetting.addChangeListener(this.populateOptions,this),e.NetworkManager.MultitargetNetworkManager.instance().addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.ConditionsChanged,(()=>{this.networkConditionsChanged()}),this),this.populateOptions()}revealAndUpdate(){n.Revealer.reveal(this.customNetworkConditionsSetting),this.networkConditionsChanged()}optionSelected(t){e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(t)}populateOptions(){const t={title:u(g.disabled),items:[e.NetworkManager.NoThrottlingConditions]},n={title:u(g.presets),items:d.networkPresets},i={title:u(g.custom),items:this.customNetworkConditionsSetting.get()};if(this.options=this.populateCallback([t,n,i]),!this.networkConditionsChanged())for(let t=this.options.length-1;t>=0;t--)if(this.options[t]){this.optionSelected(this.options[t]);break}}networkConditionsChanged(){const t=e.NetworkManager.MultitargetNetworkManager.instance().networkConditions();for(let n=0;n<this.options.length;++n){const i=this.options[n];if(i&&e.NetworkManager.networkConditionsEqual(t,i))return this.selectCallback(n),!0}return!1}}var p=Object.freeze({__proto__:null,NetworkThrottlingSelector:w});const C={sS:"{PH1}: {PH2}",add:"Add…",addS:"Add {PH1}",offline:"Offline",forceDisconnectedFromNetwork:"Force disconnected from network",throttling:"Throttling",cpuThrottlingIsEnabled:"CPU throttling is enabled",cpuThrottling:"CPU throttling",noThrottling:"No throttling",dSlowdown:"{PH1}× slowdown",excessConcurrency:"Exceeding the default value may degrade system performance.",resetConcurrency:"Reset to the default value",hardwareConcurrency:"Hardware concurrency",hardwareConcurrencyValue:"Value of navigator.hardwareConcurrency",hardwareConcurrencyIsEnabled:"Hardware concurrency override is enabled"},k=t.i18n.registerUIStrings("panels/mobile_throttling/ThrottlingManager.ts",C),M=t.i18n.getLocalizedString.bind(void 0,k);let b,m;class T{cpuThrottlingControls;cpuThrottlingRates;customNetworkConditionsSetting;currentNetworkThrottlingConditionsSetting;lastNetworkThrottlingConditions;cpuThrottlingManager;#t=!1;get hardwareConcurrencyOverrideEnabled(){return this.#t}constructor(){this.cpuThrottlingManager=e.CPUThrottlingManager.CPUThrottlingManager.instance(),this.cpuThrottlingControls=new Set,this.cpuThrottlingRates=d.cpuThrottlingPresets,this.customNetworkConditionsSetting=n.Settings.Settings.instance().moduleSetting("customNetworkConditions"),this.currentNetworkThrottlingConditionsSetting=n.Settings.Settings.instance().createSetting("preferredNetworkCondition",e.NetworkManager.NoThrottlingConditions),this.currentNetworkThrottlingConditionsSetting.setSerializer(new e.NetworkManager.ConditionsSerializer),e.NetworkManager.MultitargetNetworkManager.instance().addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.ConditionsChanged,(()=>{this.lastNetworkThrottlingConditions=this.currentNetworkThrottlingConditionsSetting.get(),this.currentNetworkThrottlingConditionsSetting.set(e.NetworkManager.MultitargetNetworkManager.instance().networkConditions())})),this.isDirty()&&e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(this.currentNetworkThrottlingConditionsSetting.get())}static instance(t={forceNew:null}){const{forceNew:e}=t;return b&&!e||(b=new T),b}decorateSelectWithNetworkThrottling(t){let e=[];const n=new w((function(n){t.removeChildren(),e=[];for(let i=0;i<n.length;++i){const o=n[i],s=t.createChild("optgroup");s.label=o.title;for(const t of o.items){const n="function"==typeof t.title?t.title():t.title,i=new Option(n,n);r.ARIAUtils.setLabel(i,M(C.sS,{PH1:o.title,PH2:n})),s.appendChild(i),e.push(t)}if(i===n.length-1){const t=new Option(M(C.add),M(C.add));r.ARIAUtils.setLabel(t,M(C.addS,{PH1:o.title})),s.appendChild(t),e.push(null)}}return e}),(function(e){t.selectedIndex!==e&&(t.selectedIndex=e)}),this.customNetworkConditionsSetting);return t.addEventListener("change",(function(){if(t.selectedIndex===t.options.length-1)n.revealAndUpdate();else{const i=e[t.selectedIndex];i&&n.optionSelected(i)}}),!1),n}createOfflineToolbarCheckbox(){const t=new r.Toolbar.ToolbarCheckbox(M(C.offline),M(C.forceDisconnectedFromNetwork),function(){if(t.checked())e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(e.NetworkManager.OfflineConditions);else{const t=this.lastNetworkThrottlingConditions.download||this.lastNetworkThrottlingConditions.upload?this.lastNetworkThrottlingConditions:e.NetworkManager.NoThrottlingConditions;e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(t)}}.bind(this));return e.NetworkManager.MultitargetNetworkManager.instance().addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.ConditionsChanged,(function(){t.setChecked(e.NetworkManager.MultitargetNetworkManager.instance().isOffline())})),t.setChecked(e.NetworkManager.MultitargetNetworkManager.instance().isOffline()),t}createMobileThrottlingButton(){const t=new r.Toolbar.ToolbarMenuButton((function(t){for(let o=0;o<e.length;++o){const r=e[o];r&&(r.title===d.getCustomConditions().title&&r.description===d.getCustomConditions().description||t.defaultSection().appendCheckboxItem(r.title,i.optionSelected.bind(i,r),n===o))}}));t.setTitle(M(C.throttling)),t.setGlyph(""),t.turnIntoSelect(),t.setDarkText();let e=[],n=-1;const i=new y((function(t){e=[];for(const n of t){for(const t of n.items)e.push(t);e.push(null)}return e}),(function(i){n=i;const o=e[i];o&&(t.setText(o.title),t.setTitle(`${o.title} ${o.description}`))}));return t}updatePanelIcon(){const t=this.cpuThrottlingManager.cpuThrottlingRate();if(t===e.CPUThrottlingManager.CPUThrottlingRates.NoThrottling&&!this.hardwareConcurrencyOverrideEnabled)return void r.InspectorView.InspectorView.instance().setPanelIcon("timeline",null);const n=new o.Icon.Icon;n.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"};const i=[];t!==e.CPUThrottlingManager.CPUThrottlingRates.NoThrottling&&i.push(M(C.cpuThrottlingIsEnabled)),this.hardwareConcurrencyOverrideEnabled&&i.push(M(C.hardwareConcurrencyIsEnabled)),n.title=i.join("\n"),r.InspectorView.InspectorView.instance().setPanelIcon("timeline",n)}setCPUThrottlingRate(t){this.cpuThrottlingManager.setCPUThrottlingRate(t),t!==e.CPUThrottlingManager.CPUThrottlingRates.NoThrottling&&i.userMetrics.actionTaken(i.UserMetrics.Action.CpuThrottlingEnabled);const n=this.cpuThrottlingRates.indexOf(t);for(const t of this.cpuThrottlingControls)t.setSelectedIndex(n);this.updatePanelIcon()}createCPUThrottlingSelector(){const t=new r.Toolbar.ToolbarComboBox((t=>this.setCPUThrottlingRate(this.cpuThrottlingRates[t.target.selectedIndex])),M(C.cpuThrottling));this.cpuThrottlingControls.add(t);const e=this.cpuThrottlingManager.cpuThrottlingRate();for(let n=0;n<this.cpuThrottlingRates.length;++n){const i=this.cpuThrottlingRates[n],o=1===i?M(C.noThrottling):M(C.dSlowdown,{PH1:i}),r=t.createOption(o);t.addOption(r),e===i&&t.setSelectedIndex(n)}return t}createHardwareConcurrencySelector(){const t=new r.Toolbar.ToolbarItem(r.UIUtils.createInput("devtools-text-input","number"));t.setTitle(M(C.hardwareConcurrencyValue));const e=t.element;e.min="1",t.setEnabled(!1);const n=new r.Toolbar.ToolbarCheckbox(M(C.hardwareConcurrency)),i=new r.Toolbar.ToolbarButton("Reset concurrency","undo");i.setTitle(M(C.resetConcurrency));const s=new o.Icon.Icon;s.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"};const a=new r.Toolbar.ToolbarItem(s);return a.setTitle(M(C.excessConcurrency)),n.inputElement.disabled=!0,i.element.classList.add("timeline-concurrency-hidden"),a.element.classList.add("timeline-concurrency-hidden"),this.cpuThrottlingManager.getHardwareConcurrency().then((o=>{if(void 0===o)return;const s=t=>{t>=1&&this.cpuThrottlingManager.setHardwareConcurrency(t),t>o?a.element.classList.remove("timeline-concurrency-hidden"):a.element.classList.add("timeline-concurrency-hidden"),t===o?i.element.classList.add("timeline-concurrency-hidden"):i.element.classList.remove("timeline-concurrency-hidden")};e.value=`${o}`,e.oninput=()=>s(Number(e.value)),n.inputElement.disabled=!1,n.inputElement.addEventListener("change",(()=>{this.#t=n.checked(),this.updatePanelIcon(),t.setEnabled(this.hardwareConcurrencyOverrideEnabled),s(this.hardwareConcurrencyOverrideEnabled?Number(e.value):o)})),i.addEventListener(r.Toolbar.ToolbarButton.Events.Click,(()=>{e.value=`${o}`,s(o)}))})),{input:t,reset:i,warning:a,toggle:n}}setHardwareConcurrency(t){this.cpuThrottlingManager.setHardwareConcurrency(t)}isDirty(){const t=e.NetworkManager.MultitargetNetworkManager.instance().networkConditions(),n=this.currentNetworkThrottlingConditionsSetting.get();return!e.NetworkManager.networkConditionsEqual(t,n)}}class N{static instance(t={forceNew:null}){const{forceNew:e}=t;return m&&!e||(m=new N),m}handleAction(t,n){return"network-conditions.network-online"===n?(e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(e.NetworkManager.NoThrottlingConditions),!0):"network-conditions.network-low-end-mobile"===n?(e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(e.NetworkManager.Slow3GConditions),!0):"network-conditions.network-mid-tier-mobile"===n?(e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(e.NetworkManager.Fast3GConditions),!0):"network-conditions.network-offline"===n&&(e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(e.NetworkManager.OfflineConditions),!0)}}function f(){return T.instance()}var v=Object.freeze({__proto__:null,ThrottlingManager:T,ActionDelegate:N,throttlingManager:f});const x={disabled:"Disabled",presets:"Presets",advanced:"Advanced"},S=t.i18n.registerUIStrings("panels/mobile_throttling/MobileThrottlingSelector.ts",x),P=t.i18n.getLocalizedString.bind(void 0,S);class y{populateCallback;selectCallback;options;constructor(t,n){this.populateCallback=t,this.selectCallback=n,e.CPUThrottlingManager.CPUThrottlingManager.instance().addEventListener(e.CPUThrottlingManager.Events.RateChanged,this.conditionsChanged,this),e.NetworkManager.MultitargetNetworkManager.instance().addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.ConditionsChanged,this.conditionsChanged,this),this.options=this.populateOptions(),this.conditionsChanged()}optionSelected(t){e.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(t.network),f().setCPUThrottlingRate(t.cpuThrottlingRate)}populateOptions(){const t={title:P(x.disabled),items:[d.getNoThrottlingConditions()]},e={title:P(x.presets),items:d.getMobilePresets()},n={title:P(x.advanced),items:d.getAdvancedMobilePresets()};return this.populateCallback([t,e,n])}conditionsChanged(){const t=e.NetworkManager.MultitargetNetworkManager.instance().networkConditions(),n=e.CPUThrottlingManager.CPUThrottlingManager.instance().cpuThrottlingRate();for(let e=0;e<this.options.length;++e){const i=this.options[e];if(i&&"network"in i&&i.network===t&&i.cpuThrottlingRate===n)return void this.selectCallback(e)}const i=d.getCustomConditions();for(let t=0;t<this.options.length;++t){const e=this.options[t];if(e&&e.title===i.title&&e.description===i.description)return void this.selectCallback(t)}}}var I=Object.freeze({__proto__:null,MobileThrottlingSelector:y});const E={networkThrottlingIsEnabled:"Network throttling is enabled",requestsMayBeRewrittenByLocal:"Requests may be rewritten by local overrides",requestsMayBeBlocked:"Requests may be blocked",acceptedEncodingOverrideSet:"The set of accepted `Content-Encoding` headers has been modified by DevTools. See the Network Conditions panel."},U=t.i18n.registerUIStrings("panels/mobile_throttling/NetworkPanelIndicator.ts",E),L=t.i18n.getLocalizedString.bind(void 0,U);var R=Object.freeze({__proto__:null,NetworkPanelIndicator:class{constructor(){if(!r.InspectorView.InspectorView.instance().hasPanel("network"))return;const t=e.NetworkManager.MultitargetNetworkManager.instance();function n(){let n=new o.Icon.Icon;n.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},t.isThrottling()?r.Tooltip.Tooltip.install(n,L(E.networkThrottlingIsEnabled)):e.NetworkManager.MultitargetNetworkManager.instance().isIntercepting()?r.Tooltip.Tooltip.install(n,L(E.requestsMayBeRewrittenByLocal)):t.isBlocking()?r.Tooltip.Tooltip.install(n,L(E.requestsMayBeBlocked)):t.isAcceptedEncodingOverrideSet()?r.Tooltip.Tooltip.install(n,L(E.acceptedEncodingOverrideSet)):n=null,r.InspectorView.InspectorView.instance().setPanelIcon("network",n)}t.addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.ConditionsChanged,n),t.addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.BlockedPatternsChanged,n),t.addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.InterceptorsChanged,n),t.addEventListener(e.NetworkManager.MultitargetNetworkManager.Events.AcceptedEncodingsChanged,n),n()}}});const O=new CSSStyleSheet;O.replaceSync(":host{overflow:hidden}.header{padding:0 0 6px;border-bottom:1px solid var(--color-details-hairline);font-size:18px;font-weight:normal;flex:none}.add-conditions-button{flex:none;margin:10px 2px;min-width:140px;align-self:flex-start}.conditions-list{max-width:500px;min-width:340px;flex:auto}.conditions-list-item{padding:3px 5px;height:30px;display:flex;align-items:center;position:relative;flex:auto 1 1}.conditions-list-text{white-space:nowrap;text-overflow:ellipsis;flex:0 0 70px;user-select:none;color:var(--color-text-primary);text-align:end;position:relative}.conditions-list-text:last-child{flex-basis:140px;text-align:left}.conditions-edit-row .conditions-list-text:last-child{text-align:right}.conditions-list-title{text-align:start;display:flex;flex:auto;align-items:flex-start}.conditions-list-title-text{overflow:hidden;flex:auto;white-space:nowrap;text-overflow:ellipsis}.conditions-list-separator{flex:0 0 1px;background-color:var(--color-background-elevation-2);height:30px;margin:0 4px}.conditions-list-separator-invisible{visibility:hidden;height:100%!important}.conditions-edit-row{flex:none;display:flex;flex-direction:row;margin:6px 5px}.conditions-edit-row input{width:100%;text-align:inherit}.conditions-edit-optional{position:absolute;bottom:-20px;right:0;color:var(--color-text-disabled)}.editor-buttons{margin-top:10px}\n/*# sourceURL=throttlingSettingsTab.css */\n");const A={networkThrottlingProfiles:"Network Throttling Profiles",addCustomProfile:"Add custom profile...",dms:"{PH1} `ms`",profileName:"Profile Name",download:"Download",upload:"Upload",latency:"Latency",optional:"optional",profileNameCharactersLengthMust:"Profile Name characters length must be between 1 to {PH1} inclusive",sMustBeANumberBetweenSkbsToSkbs:"{PH1} must be a number between {PH2} `kbit/s` to {PH3} `kbit/s` inclusive",latencyMustBeAnIntegerBetweenSms:"Latency must be an integer between {PH1} `ms` to {PH2} `ms` inclusive",dskbits:"{PH1} `kbit/s`",fsmbits:"{PH1} `Mbit/s`"},H=t.i18n.registerUIStrings("panels/mobile_throttling/ThrottlingSettingsTab.ts",A),_=t.i18n.getLocalizedString.bind(void 0,H);let B;class z extends r.Widget.VBox{list;customSetting;editor;constructor(){super(!0);const t=this.contentElement.createChild("div","header");t.textContent=_(A.networkThrottlingProfiles),r.ARIAUtils.markAsHeading(t,1);const e=r.UIUtils.createTextButton(_(A.addCustomProfile),this.addButtonClicked.bind(this),"add-conditions-button");this.contentElement.appendChild(e),this.list=new r.ListWidget.ListWidget(this),this.list.element.classList.add("conditions-list"),this.list.show(this.contentElement),this.customSetting=n.Settings.Settings.instance().moduleSetting("customNetworkConditions"),this.customSetting.addChangeListener(this.conditionsUpdated,this),this.setDefaultFocusedElement(e)}static instance(t={forceNew:null}){const{forceNew:e}=t;return B&&!e||(B=new z),B}wasShown(){super.wasShown(),this.list.registerCSSFiles([O]),this.registerCSSFiles([O]),this.conditionsUpdated()}conditionsUpdated(){this.list.clear();const t=this.customSetting.get();for(let e=0;e<t.length;++e)this.list.appendItem(t[e],!0);this.list.appendSeparator()}addButtonClicked(){this.list.addNewItem(this.customSetting.get().length,{title:()=>"",download:-1,upload:-1,latency:0})}renderItem(t,e){const n=document.createElement("div");n.classList.add("conditions-list-item");const i=n.createChild("div","conditions-list-text conditions-list-title").createChild("div","conditions-list-title-text"),o=this.retrieveOptionsTitle(t);return i.textContent=o,r.Tooltip.Tooltip.install(i,o),n.createChild("div","conditions-list-separator"),n.createChild("div","conditions-list-text").textContent=D(t.download),n.createChild("div","conditions-list-separator"),n.createChild("div","conditions-list-text").textContent=D(t.upload),n.createChild("div","conditions-list-separator"),n.createChild("div","conditions-list-text").textContent=_(A.dms,{PH1:t.latency}),n}removeItemRequested(t,e){const n=this.customSetting.get();n.splice(e,1),this.customSetting.set(n)}retrieveOptionsTitle(t){return"function"==typeof t.title?t.title():t.title}commitEdit(t,e,n){t.title=e.control("title").value.trim();const i=e.control("download").value.trim();t.download=i?125*parseInt(i,10):-1;const o=e.control("upload").value.trim();t.upload=o?125*parseInt(o,10):-1;const r=e.control("latency").value.trim();t.latency=r?parseInt(r,10):0;const s=this.customSetting.get();n&&s.push(t),this.customSetting.set(s)}beginEdit(t){const e=this.createEditor();return e.control("title").value=this.retrieveOptionsTitle(t),e.control("download").value=t.download<=0?"":String(t.download/125),e.control("upload").value=t.upload<=0?"":String(t.upload/125),e.control("latency").value=t.latency?String(t.latency):"",e}createEditor(){if(this.editor)return this.editor;const e=new r.ListWidget.Editor;this.editor=e;const n=e.contentElement(),i=n.createChild("div","conditions-edit-row"),o=i.createChild("div","conditions-list-text conditions-list-title"),s=_(A.profileName);o.createChild("div","conditions-list-title-text").textContent=s,i.createChild("div","conditions-list-separator conditions-list-separator-invisible");const a=i.createChild("div","conditions-list-text"),l=_(A.download);a.createChild("div","conditions-list-title-text").textContent=l,i.createChild("div","conditions-list-separator conditions-list-separator-invisible");const d=i.createChild("div","conditions-list-text").createChild("div","conditions-list-title-text"),c=_(A.upload);d.textContent=c,i.createChild("div","conditions-list-separator conditions-list-separator-invisible");const g=i.createChild("div","conditions-list-text"),h=_(A.latency);g.createChild("div","conditions-list-title-text").textContent=h;const u=n.createChild("div","conditions-edit-row"),w=e.createInput("title","text","",(function(t,e,n){const i=n.value.trim(),o=i.length>0&&i.length<=49;if(!o){const t=_(A.profileNameCharactersLengthMust,{PH1:49});return{valid:o,errorMessage:t}}return{valid:o,errorMessage:void 0}}));r.ARIAUtils.setLabel(w,s),u.createChild("div","conditions-list-text conditions-list-title").appendChild(w),u.createChild("div","conditions-list-separator conditions-list-separator-invisible");let p=u.createChild("div","conditions-list-text");const C=e.createInput("download","text",t.i18n.lockedString("kbit/s"),T);p.appendChild(C),r.ARIAUtils.setLabel(C,l);const k=p.createChild("div","conditions-edit-optional"),M=_(A.optional);k.textContent=M,r.ARIAUtils.setDescription(C,M),u.createChild("div","conditions-list-separator conditions-list-separator-invisible"),p=u.createChild("div","conditions-list-text");const b=e.createInput("upload","text",t.i18n.lockedString("kbit/s"),T);r.ARIAUtils.setLabel(b,c),p.appendChild(b);p.createChild("div","conditions-edit-optional").textContent=M,r.ARIAUtils.setDescription(b,M),u.createChild("div","conditions-list-separator conditions-list-separator-invisible"),p=u.createChild("div","conditions-list-text");const m=e.createInput("latency","text",t.i18n.lockedString("ms"),(function(t,e,n){const i=1e6,o=n.value.trim(),r=Number(o),s=Number.isInteger(r)&&r>=0&&r<=i;if(!s){const t=_(A.latencyMustBeAnIntegerBetweenSms,{PH1:0,PH2:i});return{valid:s,errorMessage:t}}return{valid:s,errorMessage:void 0}}));r.ARIAUtils.setLabel(m,h),p.appendChild(m);return p.createChild("div","conditions-edit-optional").textContent=M,r.ARIAUtils.setDescription(m,M),e;function T(t,e,n){const i=1e7,o=n.value.trim(),r=Number(o),s=n.getAttribute("aria-label"),a=!Number.isNaN(r)&&r>=0&&r<=i;if(!a){return{valid:a,errorMessage:_(A.sMustBeANumberBetweenSkbsToSkbs,{PH1:String(s),PH2:0,PH3:i})}}return{valid:a,errorMessage:void 0}}}}function D(t){if(t<0)return"";const e=t/125;if(e<1e3)return _(A.dskbits,{PH1:e});if(e<1e4){const t=(e/1e3).toFixed(1);return _(A.fsmbits,{PH1:t})}return _(A.fsmbits,{PH1:e/1e3|0})}var j=Object.freeze({__proto__:null,ThrottlingSettingsTab:z});export{I as MobileThrottlingSelector,R as NetworkPanelIndicator,p as NetworkThrottlingSelector,v as ThrottlingManager,c as ThrottlingPresets,j as ThrottlingSettingsTab};
